<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>疫苗厂商配置管理</title>
<meta name="decorator" content="default"/>
<script src="${ctxStatic}/common/change/change.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		//$("#name").focus();
		initVaccName(bsCompanyConfig.companyCode,bsCompanyConfig.vaccineId);
		initVaccCompanyName(bsCompanyConfig.companyCode,bsCompanyConfig.companyName);
		$("#inputForm").validate({
			submitHandler: function(form){
				debugger;
				$("#companyName").val($("#companyCode").find("option:selected").text());
				if('${bsCompanyConfig.id} '!= ''){
					debugger;
					var vaccineName = $("#vaccineId").find("option:selected").text();
					$("#vaccineName").val(vaccineName.substring(0,vaccineName.indexOf('[')));
				}
				layer.confirm('确定保存？', {
					icon: 3, title:'提示',
					btn : [ '保存', '取消' ]
				}, function() {
					layer.load(2);
					loading('正在提交，请稍等...');
					form.submit();
				});
			},
			errorContainer: "#messageBox",
			errorPlacement: function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			}
		});
	});
	var bsCompanyConfig = JSON.parse('${fns:toJson(bsCompanyConfig)}');
	$('#vaccineId').val("${bsCompanyConfig.vaccineId}".split(','));
	$('#vaccineId').trigger('change.select2');
</script>
<style type="text/css">
     .autoWidth {
	     width: 271px;
	 }	
	 .select2-choices{
	     border-radius: 4px;
	 }
	 .input-xlarge-search {
		 width: 210px;
     }
</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li>
			<a href="${ctx}/company/bsCompanyConfig/">疫苗厂商规则列表</a>
		</li>
		<li class="active">
			<a href="${ctx}/company/bsCompanyConfig/form?id=${bsCompanyConfig.id}">疫苗厂商规则<shiro:hasPermission name="company:bsCompanyConfig:edit">${not empty bsCompanyConfig.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="company:bsCompanyConfig:edit">查看</shiro:lacksPermission></a>
		</li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="bsCompanyConfig" action="${ctx}/company/bsCompanyConfig/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input id="companyName" type="hidden" name="companyName">
		<input id="vaccineName" type="hidden" name="vaccineName">
		<sys:message content="${message}"/>	
		<div class="control-group">
			<label class="control-label"><font color="red">*</font>地区：</label>
			<div class="controls">
                <sys:treeselect2 id="areaCode" name="areaCode" value="${bsCompanyConfig.areaCode}" labelName="areaName" labelValue="${bsCompanyConfig.areaName}" module = "true"
			        title="机构" url="/sys/office/treeData" extId="${office.id}" cssClass="input-xlarge-search" allowClear="${office.currentUser.admin}"/>
			</div>
		</div>	
		<div class="control-group">
			<label class="control-label"><font color="red">*</font>生产企业：</label>
			<div class="controls">
				<form:select path="companyCode" id="companyCode" class="span3 minWidth vaccCompanyName required">
				    <form:option value="" label="--请选择--"/> 
				</form:select>
				<span class="help-inline"><font color="red"></font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><font color="red">*</font>疫苗名称：</label>
			<div class="controls">
				<form:select path="vaccineId" id="vaccineId" class="span7 minWidth vaccineCompany autoWidth required" multiple="true">
					<form:option value="" label="--请选择--"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><font color="red">*</font>启用状态：</label>
			<div class="controls">
				<form:radiobuttons path="isEnable" items="${fns:getDictList('is_enable')}"
					itemLabel="label" itemValue="value" class="required" />
				<span class="help-inline type-msg error"><font color="red"></font></span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="company:bsCompanyConfig:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>